<?php
namespace Admin\Controller;
use Think\Controller;
class ComplainController extends BaseController {
	//待解决的投诉
		public function add(){
			$com = M("complain");
			$count = $com -> where('status=0') -> count();
			$page = new \Think\Page($count,10);
			$show = $page -> show();
			$result = $com->where("status = 0")->limit($page->firstRow.','.$page->listRows)->select();
			$this->assign("show",$show);
			$this->assign("result",$result);
			$this->display();
		}
		//查看投诉
		public function view(){
			$com = M("complain");
			$result = $com->where("id = {$_GET['id']}")->find();
			$this->assign("data",$result);
			$this->display();
		}
		//解决的投诉
		public function save(){
			$com = M("complain");
			// dump(I());die;
			$id = $_GET["id"];
			$save['status']= 0;
			$com->where("id = {$id}")->save($save);
			if($com){
				$this->success('解决成功',U('Admin/Complain/add'),1);
			}else{
				 //var_dump($phone->_sql()) ;die();
				$this->error('解决失败',U('Admin/Complain/index'),99999);
			}
			// header("location:/admin.php/Complain/add");
		}
		//以解决的投诉
		public function index(){
			$com = M("complain");
			$count = $com -> where('status = 1')-> count();
			$page = new \Think\Page($count,10);
			$show = $page -> show();
			$result = $com->where("status =1")->limit($page->firstRow.','.$page->listRows)->select();

			$this->assign("show",$show);
			$this->assign("result",$result);
			$this->display();
		}
		//删除以解决的投诉
		public function del(){
			$com = M("complain");
			$com ->where("id = {$_GET['id']}")->delete();
			if($com){
				$this->success('删除成功',U('Admin/Complain/add'),1);
			}else{
				 //var_dump($phone->_sql()) ;die();
				$this->error('删除失败',U('Admin/Complain/index'),99999);
			}
			// header("location:".$_SERVER["HTTP_REFERER"]);
		}

	}
?>